/**
 * AjLog - The AspectJ based logging facade
 *
 * Copyright (C) 2009 - 2010, Marko Umek. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ajlog.core.logging;

import org.ajlog.loglog.ILogger;
import org.ajlog.loglog.LoggerFactory;

/**
 * AbstractLoggingFramework is the base for the type safe implementation of
 * {@link ILoggingFramework}. <br/>
 * <br/>
 * <b>Recommendation:</b> Any implementation of {@link ILoggingFramework} should
 * use this base class.
 * 
 * @author Marko Umek
 * 
 */
public abstract class AbstractLoggingFramework<LOGGER>
    implements ILoggingFramework {

    /**
     * Constructor
     * 
     */
    public AbstractLoggingFramework() {
        super();
    }

    /* (non-Javadoc)
     * @see org.ajlog.core.logging.ILoggingFramework#createLoggingInstance(java.lang.String)
     */
    public final Object createLoggingInstance(final String name) {
        return this.doCreateLoggingInstance(name);
    }

    /**
     * doCreateLoggingInstance creates a logger instance (of the underlying
     * logging framework) associated with {@code name}. Thus this method
     * provides a type safe implementation of
     * {@link #createLoggingInstance(String)}.
     * 
     * @param name
     *            the classes name.
     * @return the logger instance
     * 
     * @see #createLoggingInstance(String)
     */
    protected abstract LOGGER doCreateLoggingInstance(final String name);

    /* (non-Javadoc)
     * @see org.ajlog.core.logging.ILoggingFramework#setupFilterLevelMapper()
     */
    public final IAjLogLevelMapper setupLevelMapper() {
        return this.doSetupLevelMapper(new AjLogLevelMapper<LOGGER>());
    }

    /**
     * doSetupLevelMapper provides a type safe implementation of
     * {@link #setupLevelMapper()}.
     * 
     * @param ajLogLevelMapper
     *            the AjLog Level mapping instance
     * 
     * @return the mapping instance
     * 
     * @see #setupLevelMapper()
     */
    protected abstract IAjLogLevelMapper doSetupLevelMapper(AjLogLevelMapper<LOGGER> ajLogLevelMapper);

    /*
     * (non-Javadoc)
     * @see org.ajlog.core.logging.ILoggingFramework#createInternalLoggingInstance(java.lang.Class)
     */
    public ILogger createInternalLoggingInstance(final Class<?> clazz) {
        return LoggerFactory.getLogger(clazz);
    }

}